package itheima.moc.ServerSocketDEMO7;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerSocketDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(9999);

        Socket accept = ss.accept();
        InputStream is = accept.getInputStream();
        int b;
        while ((b = is.read()) != -1) {
            System.out.print((char) b);
        }

        BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        fw.write("呵呵哒 who are you");
        fw.newLine();
        fw.flush();

        fw.close();
        accept.close();
        ss.close();

    }
}
